import java.io.IOException;
import java.util.Scanner;


public class DormitoryManagementSystem {
    public static void main(String[] args) throws IOException {
        // 创建宿舍管理器，指定男生 5 个宿舍，女生 5 个宿舍，每个宿舍 6 张床
        DormitoryManager dormitoryManager =
                new DormitoryManager(5, 5, 6);
        boolean restore = dormitoryManager.restore();
        if(restore) {
            System.out.println("已加载数据");
        }
        Scanner scanner = new Scanner(System.in);
        int option;

        do {
            System.out.println("请选择操作：");
            System.out.println("1. 查看空闲床位");
            System.out.println("2. 查看指定宿舍信息");
            System.out.println("3. 添加学生");
            System.out.println("4. 搜索学生住处");
            System.out.println("5. 宿舍卫生评比");
            System.out.println("6. 添加违规物品警告");
            System.out.println("7. 导入学生");
            System.out.println("0. 退出");
            option = scanner.nextInt();
            int dormitoryNumber;
            String gender;
            switch (option) {
                case 1:
                    System.out.println("请输入学生性别（男/女）：");
                    gender = scanner.next();
                    dormitoryManager.displayAvailableBeds(gender);
                    break;
                case 2:
                    System.out.println("请输入男寝还是女寝（男/女）：");
                    gender = scanner.next();
                    System.out.println("请输入宿舍号：");
                    dormitoryNumber = scanner.nextInt();
                    dormitoryManager.displayDormitoryInfo(gender, dormitoryNumber);
                    break;
                case 3:
                    System.out.println("请输入学生姓名：");
                    String name = scanner.next();
                    System.out.println("请输入学生性别（男/女）：");
                    gender = scanner.next();
                    System.out.println("请输入宿舍号：");
                    dormitoryNumber = scanner.nextInt();
                    System.out.println("请输入床位号：");
                    int bedNumber = scanner.nextInt();
                    dormitoryManager.addStudent(name, gender, dormitoryNumber, bedNumber);
                    dormitoryManager.store();
                    break;
                case 4:
                    System.out.println("请输入学生性别（男/女）：");
                    gender = scanner.next();
                    System.out.println("请输入学生姓名：");
                    name = scanner.next();
                    dormitoryManager.searchStudent(gender, name);
                    break;
                case 5:
                    System.out.println("请输入男寝还是女寝（男/女）：");
                    gender = scanner.next();
                    System.out.println("请输入宿舍号：");
                    dormitoryNumber = scanner.nextInt();
                    System.out.println("请输入评分（0-100）：");
                    int score = scanner.nextInt();
                    dormitoryManager.rateDormitory(gender, dormitoryNumber, score);
                    break;
                case 6:
                    System.out.println("请输入男寝还是女寝（男/女）：");
                    gender = scanner.next();
                    System.out.println("请输入宿舍号：");
                    dormitoryNumber = scanner.nextInt();
                    System.out.println("请输入警告信息：");
                    String warning = scanner.next();
                    dormitoryManager.addWarning(gender, dormitoryNumber, warning);
                    break;
                case 7:
                    System.out.println("请输入Excel文件路径：");
                    String filePath = scanner.next();
                    dormitoryManager.importExcel(filePath);
                    break;
                case 0:
                    System.out.println("感谢使用宿舍管理系统，再见！");
                    break;
                default:
                    System.out.println("无效的选项，请重新输入！");
                    break;
            }
        } while (option != 0);

        scanner.close();
    }
}
